<template>
    <div>
        <!-- <h1>{{ a.b }}</h1>
        <button @click="a.b++">自增</button> -->
        <input type="text" v-model="c">
        <h3>{{ c }}</h3>

        <button @click="e++">{{ d }}</button>
    </div>
</template>


<script setup>
import { customRef, reactive, ref } from 'vue';
const a=reactive({
    b:10
})
// console.log(a);

function myRef(value){
    return customRef((track,trigger)=>{
        return {
            get(){
                track()//记录追踪
                return value
                // console.log(track());
            },
            set(newVal){
                value=newVal
                trigger()//触发更改
            }
        }
    })
}
const c =myRef('000')

const d=myRef(10)
const e=ref(10)
console.log(d);
console.log(e);





</script>



<style scoped></style>